﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;

using System.Windows.Forms;
using System.Data.SqlClient;
using System.Xml.Serialization;
using System.IO;
using System.Collections.Specialized;

namespace SQLComparer
{
    public class Connection
    {
        public string Name { get; set; }
        public string Server { get; set; }
        public string Database { get; set; }
        public string UserID { get; set; }
        public string Password { get; set; }
        public string ConnectionString { get; set; }

        public static List<Connection> Deserialize()
        {
            string path = Application.StartupPath + "\\Connection.xml";
            if (File.Exists(path))
            {
                XmlSerializer s = new XmlSerializer(typeof(List<Connection>));
                FileStream fs = File.Open(path, FileMode.Open);
                List<Connection> ret = (List<Connection>)s.Deserialize(fs);
                fs.Close();
                return ret;

            }
            else
            {
                return new List<Connection>();
            }
        }
        public static void Serialize(List<Connection> o)
        {
            string path = Application.StartupPath + "\\Connection.xml";
            if (File.Exists(path))
            {
                File.Delete(path);
            }
            XmlSerializer s = new XmlSerializer(typeof(List<Connection>));
            FileStream fs = File.Open(path, FileMode.CreateNew);
            s.Serialize(fs, o);
            fs.Close();
        }
    }
    public class Exclude
    {
        public string Name { get; set; }
        public string Type { get; set; }
        public string Schema { get; set; }

        public static List<Exclude> Deserialize()
        {
            string path = Application.StartupPath + "\\Exclude.xml";
            if (File.Exists(path))
            {
                XmlSerializer s = new XmlSerializer(typeof(List<Exclude>));
                FileStream fs = File.Open(path, FileMode.Open);
                List<Exclude> ret = (List<Exclude>)s.Deserialize(fs);
                fs.Close();
                return ret;

            }
            else
            {
                return new List<Exclude>();
            }
        }
        public static void Serialize(List<Exclude> o)
        {
            string path = Application.StartupPath + "\\Exclude.xml";
            if (File.Exists(path))
            {
                File.Delete(path);
            }
            XmlSerializer s = new XmlSerializer(typeof(List<Exclude>));
            FileStream fs = File.Open(path, FileMode.CreateNew);
            s.Serialize(fs, o);
            fs.Close();
        }


    }
    public class Different
    {
        public string NameA { get; set; }
        public string TypeA { get; set; }
        public string SchemaA { get; set; }
        public string ScriptA { get; set; }
        public string NameB { get; set; }
        public string TypeB { get; set; }
        public string SchemaB { get; set; }
        public string ScriptB { get; set; }
    }
}
